package com.tyj.movie.controller;


import com.tyj.movie.entity.MovieComment;
import com.tyj.movie.service.MovieCommentService;
import com.tyj.movie.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tyj
 * @since 2021-06-28
 */
@RestController
@RequestMapping("/movie/comment")
public class MovieCommentController {

    @Autowired
    MovieCommentService movieCommentService;

    @PreAuthorize("hasAuthority('comment')")
    @PostMapping("/add")
    public R addComment(MovieComment movieComment){
       R r= movieCommentService.addComment(movieComment);
        return r;
    }

    @PreAuthorize("hasAuthority('like')")
    @PostMapping("/giveLike/{id}/{movieId}")
    public R giveLike(@PathVariable Long id,@PathVariable("movieId") Long movieId){
       R r = movieCommentService.giveLike(id,movieId);
        return r;
    }

}

